<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
    function ran(N,M){
        return Math.floor(Math.random()*(M-N+1))+N
    }
let sj = ran(1,10)// console.log(sj)
    for(i=1;i<=3;i++){
        let num = +prompt('请输入一个数字')
        if(num >sj){
         alert('猜大了')
         alert(`你还有${3-i}次机会`)
        }else if(num< sj){
         alert('猜小了')
          alert(`你还有${3-i}次机会`)
        }else {
         alert('猜对啦')
         break
        }
    }
   </script>
</body>
</html>